interface FaceQu {
    callBack?: (val?: any) => void
}
export class Queque implements FaceQu {
    callBack(val:any) {
        return 123
    }
    quque: any[] = []
    limitTime = 0
    timer = null
    constructor({ quque = [], limitTime = 300, callBack }) {
        this.limitTime = limitTime
        this.callBack = callBack
        this.quque = quque
        if (quque.length > 0 && !this.timer) {
            this.start()
        }
    }
    add(val) {
        this.quque.push(val)
        if (!this.timer) {
            this.start()
        }
    }
    out() {
        if (this.quque.length === 0) {
            this.stop()
        } else {
            this.callBack && this.callBack(this.quque.shift())
        }
    }
    start() {
        this.timer = setInterval(this.out.bind(this), this.limitTime)
    }
    stop() {
        clearInterval(this.timer)
        this.timer = null
    }
    clear() {
        this.stop()
        this.quque = []
    }
}